﻿@model Tasker.WebUI.Models.StaffListModel
           
@{
    ViewBag.Title = "Сотрудники";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

    $(document).ready(function () {
        $('#add-subtask').css("display", "none");
        $('.employee-table tr').click(function () {
            if ($(this).hasClass('selected')) {
                $(this).removeClass('selected');
                $('#add-subtask').css("display", "none");
                $('#add-task').css("display", "block");
            } else {
                $('.employee-table tr').removeClass('selected');
                $(this).addClass('selected');
                $('#add-subtask').css("display", "block");
                $('#employeeId').val($(this).attr('uid'));
                $('#add-task').css("display", "none");
            }
        });
    });

</script>

<div>
    <a href="@Url.Action("Create", "Task")" id="add-task"  class="btn btn-primary" style="float: right;">
        Поставить задачу
    </a>
    @using (Html.BeginForm("CreateTaskEmployee", "Task", FormMethod.Post))
    {
        <input type="hidden" id="employeeId" name="employeeId" value=""/>
        <a href="javascript:;" id="add-subtask" onclick="$(this).parents('form').submit();"  class="btn btn-primary" style="float: right;">
            Поставить задачу
        </a>
    }
</div>

<h2>Сотрудники</h2>

<div id="employeeContentContainer">
    <table class="items-table employee-table">
        <thead>
            <tr>
                <th class="c-ltr">
                    <div class="inner">
                        
                    </div>
                </th>
                <th class="c-ph"></th>
                <th class="c-nm" width="30%">
                    <div class="inner">
                        <div>
                            <a href="#">Имя</a>													
                        </div>
                    </div>
                </th>
                <th class="c-pos" width="20%">
                    <div class="inner sortasc">
                        <div>
                            <a href="#">Должность</a>											
                        </div>
                    </div>
                </th>
                <th class="c-email" width="25%">
                    <div class="inner">
                        <div>
                            <a href="?sortby=Email">Электропочта</a>	
                        </div>
                    </div>
                </th>
                <th class="c-mob">
                    <div class="inner">
                        <div>
                            Телефон
                        </div>
                    </div>
                </th>
            </tr>
        </thead>
        <tbody>
            @foreach (var staff in Model.staff)
            {
                <tr id="e1000007" class="item s22" uid="@staff.Id">
                    <td class="c-ltr">
                        <div class="inner">&nbsp;</div>
                    </td>
                    <td class="c-ph">
                    </td>
                    <td class="c-nm">
                        <div class="inner">
                            <a href="@Url.Action("ShowProfile", "Staff", new {id=staff.Id})">@staff.FullName</a>
                        </div>
                    </td>
                    <td class="c-pos">
                        <div class="inner">@staff.Position</div>
                    </td>
                    <td class="c-email">
                        <div class="inner">
                            @foreach (var email in staff.Emails)
                            {
                                <a href="mailto:@email">
                                    @email
                                </a>
                                <br />
                            }
                        </div>
                    </td>
                
                    <td class="c-mob">
                        <div class="inner">
                            @foreach (var phone in staff.Phones)
                            {
                                @phone
                                <br />
                            }
                        </div>
                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>
